package com.dtsz.m2.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.dtsz.m2.R;
import com.dtsz.m2.refresh.baseadapter.CommonAdapter;
import com.dtsz.m2.refresh.baseadapter.ViewHolder;
import com.dtsz.m2.ui.activity.OrderDetailsActivity;
import com.dtsz.m2.ui.model.EcologyOrder;

import java.util.List;

public class MyEcologyOrderAdatper extends CommonAdapter<EcologyOrder> {
    private Context mContent;

    public MyEcologyOrderAdatper(Context context, int layoutId, List<EcologyOrder> datas) {
        super(context, layoutId, datas);
        mContent = context;
    }

    @Override
    protected void convert(ViewHolder holder, final EcologyOrder ecologyOrder, int position) {
        String state = ecologyOrder.getBeoState();
        holder.setText(R.id.tv_time, ecologyOrder.getCreateTimeStr());
        switch (state) {
            case "1":
                holder.setText(R.id.tv_red, "支出");
                holder.setBackgroundRes(R.id.iv_red, R.drawable.radius100_red);
                //           holder.setImageResource(R.id.iv_image,   mContent.getResources().getDrawable(R.drawable.radius100_red));
                holder.setTextColorRes(R.id.tv_red, R.color.colorMainLight2);
                holder.setText(R.id.tv_price, "-" + ecologyOrder.getBeoPrice() + "㎡");
                break;
            default:
                holder.setText(R.id.tv_red, "收入");
                holder.setBackgroundRes(R.id.iv_red, R.drawable.radius100_green);
                holder.setTextColorRes(R.id.tv_red, R.color.colorMainLight3);
                holder.setText(R.id.tv_price, "+" + ecologyOrder.getBeoPrice() + "㎡");
                break;

        }
        holder.setOnClickListener(R.id.ll_click, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(mContent, OrderDetailsActivity.class);
                intent.putExtra("orderId", ecologyOrder.getId());
                mContent.startActivity(intent);

            }
        });
    }
}
